//package yb.ecp.fast.user.web;
//
//import com.alibaba.fastjson.JSON;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.client.RestTemplate;
//import yb.ecp.fast.infra.infra.ActionResult;
//import yb.ecp.fast.user.exception.AuthException;
//import yb.ecp.fast.user.infra.BasicController;
//import yb.ecp.fast.user.service.ProfileService;
//
//import javax.annotation.Resource;
//import java.util.HashMap;
//import java.util.Map;
//
//@RestController
//@RequestMapping("/erp")
//public class ErpController extends BasicController {
//
////	@Value("${erp.code}")
////	private String code;
////
////	@Value("${erp.name}")
////	private String name;
////
////	@Value("${erp.account}")
////	private String account;
////
////	@Value("${erp.password}")
////	private String password;
////
////	@Value("${erp.system-id}")
////	private String systemId;
////
////	@Value("${erp.token-url}")
////	private String tokenUrl;
////
////	@Value("${erp.check-url}")
////	private String checkUrl;
//
//	@Resource(name = "restTemplate")
//	private RestTemplate restTemplate;
//
//	@Autowired
//	private ProfileService profileService;
//
//	@RequestMapping(value="login", method=RequestMethod.GET)
//	public ActionResult<?> login(String ssoToken) throws Exception {
//		String accessToken = getToken();
//		String erpCode = getErpCode(ssoToken, accessToken);
//		return actionResult(profileService.getUserIdByErpCode(erpCode));
//	}
//
////	private String getErpCode(String ssoToken, String accessToken) throws Exception {
////		String erpParam = getErpParam(ssoToken, accessToken);
////		Map resultMap = restTemplate.getForObject(checkUrl + "?para={erpParam}", Map.class, erpParam);
////		String erpCode = (String) resultMap.get("main.CODE");
////		if(StringUtils.isEmpty(erpCode)) {
////			throw new AuthException((String)resultMap.get("error"));
////		}
////		return erpCode;
////	}
//
////	private String getErpParam(String ssoToken, String accessToken) {
////		Map<String, String> map = getReqMap();
////		Map<String, Object> erpMap = new HashMap<String, Object>();
////		erpMap.put("req", map);
////		erpMap.put("ssotoken", ssoToken);
////		erpMap.put("accesstoken", accessToken);
////		return JSON.toJSONString(erpMap);
////	}
//
////	private String getToken() {
////		String tokenParam = getTokenParam();
////		Map resultMap = restTemplate.getForObject(tokenUrl + "?para={tokenParam}", Map.class, tokenParam);
////		String accessToken = (String) resultMap.get("AccessToken");
////		return accessToken;
////	}
//
////	private String getTokenParam() {
////		Map<String, String> map = getReqMap();
////		Map<String, Object> tokenMap = new HashMap<String, Object>();
////		tokenMap.put("req", map);
////		tokenMap.put("account", account);
////		tokenMap.put("pwd", password);
////		tokenMap.put("systemid", systemId);
////		return JSON.toJSONString(tokenMap);
////	}
//
////	private Map<String, String> getReqMap() {
////		Map<String, String> map = new HashMap<String, String>();
////		map.put("code", code);
////		map.put("name", name);
////		return map;
////	}
//
//	@RequestMapping(value="getUserIdByErpCode", method=RequestMethod.GET)
//	public ActionResult getUserIdByErpCode(String erpCode) throws Exception {
//		return actionResult(profileService.getUserIdByErpCode(erpCode));
//	}
//}
